const { data } = require('./data')
const utils = require('../../../../utils')
Component({
  data: {
    barrage1: [],
    // barrage2: [],
    // barrage3: [],
    delay1: 1,
    // delay2: 1,
    // delay3: 1,
  },
  properties: {
    isFullScreen: false
  },
  lifetimes: {
    attached() {
      const arr = this.shuffleArray(data)
      this.setData({
        barrage1: arr.slice(0, 49),
        // barrage2: arr.slice(50, 99),
        // barrage3: arr.slice(100, 150),
        delay1: this.randomNum(0.5, 3),
        // delay2: this.randomNum(0.5, 3),
        // delay3: this.randomNum(0.5, 3),
      })
    }
  },
  methods: {
    randomNum(min, max) {
      return (Math.random() * (max - min + 1) + min).toFixed(2)
    },
    //  随机打乱顺序
    shuffleArray(array) {
      for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
      }
      return array;
    }
  }
})